package com.panshi.controller.article;

import com.panshi.api.ArticleApi;
import com.panshi.pagevo.PageBeanVo;
import com.panshi.po.ArticlePo;
import com.panshi.vo.ResponseVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.util.List;

@Controller
@Slf4j
@RequestMapping("/comm")
public class CommentController {

    @Resource
    private ArticleApi articleApi;

    @PostMapping("/pv")
    public ModelAndView articleFind(Integer currentPageSize){
        ModelAndView mav = new ModelAndView("comment/middle");

        PageBeanVo pageBeanVo = new PageBeanVo();
        pageBeanVo.setCurrentPage(1);
        pageBeanVo.setPageSize(currentPageSize);

        ResponseVO<List<ArticlePo>> ranking = articleApi.pvLimitQuery(pageBeanVo);
        List<ArticlePo> rankingList = ranking.getData();

        mav.addObject("ranking",rankingList);

        return mav;
    }

}
